/*
  Copyright (c) 2010 Les Newell. All rights reserved

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


#include "wx_pch.h"
#include "GUIApp.h"

//(*AppHeaders
#include "MainFrame.h"
#include <wx/xrc/xmlres.h>
#include <wx/image.h>
//*)
#include <wx/fileconf.h>
#include <wx/stdpaths.h>

IMPLEMENT_APP(GUIApp);

bool GUIApp::OnInit()
{
    wxStandardPaths pths;
    wxString path = pths.GetUserLocalDataDir();
    path += wxString::Format(_T("/%s.ini"),wxApp::GetAppName().c_str());
    wxFileName dir(path);
    dir.Mkdir(0777,wxPATH_MKDIR_FULL);
    wxFileConfig * cfg = new wxFileConfig(wxEmptyString,wxEmptyString,path,wxEmptyString,wxCONFIG_USE_LOCAL_FILE);
    wxConfigBase::Set(cfg);
    //(*AppInitialize
    bool wxsOK = true;
    wxInitAllImageHandlers();
    wxXmlResource::Get()->InitAllHandlers();
    wxsOK = wxsOK && wxXmlResource::Get()->Load(_T("TerminalDialog.xrc"));
    wxsOK = wxsOK && wxXmlResource::Get()->Load(_T("ConfigDialog.xrc"));
    wxsOK = wxsOK && wxXmlResource::Get()->Load(_T("MainFrame.xrc"));
    if ( wxsOK )
    {
    	MainFrame* Frame = new MainFrame(0);
    	Frame->Show();
    	SetTopWindow(Frame);
    }
    //*)
    return wxsOK;

}
